package LanQiao._14JavaB;

import java.util.Scanner;

public class _4矩形总面积 {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int x1 = scan.nextInt();
        int y1 = scan.nextInt();
        int x2 = scan.nextInt();
        int y2 = scan.nextInt();
        int x3 = scan.nextInt();
        int y3 = scan.nextInt();
        int x4 = scan.nextInt();
        int y4 = scan.nextInt();
        long area1 = (long) (x2 - x1) * (y2 - y1);
        long area2 = (long) (x4 - x3) * (y4 - y3);
        long area3 = 0;
        double ox1 = (double) (x1 + x2) / 2;
        double oy1 = (double) (y1 + y2) / 2;
        double ox2 = (double) (x3 + x4) / 2;
        double oy2 = (double) (y3 + y4) / 2;
        double diffx = Math.abs(ox1 - ox2);
        double diffy = Math.abs(oy1 - oy2);
        double halfx1 = (double) (x2 - x1) / 2;
        double halfy1 = (double) (y2 - y1) / 2;
        double halfx2 = (double) (x4 - x3) / 2;
        double halfy2 = (double) (y4 - y3) / 2;
        if (diffx >= halfx1 + halfx2 || diffy >= halfy1 + halfy2) {
            area3 = 0;
        }else if (diffx <= Math.abs(halfx1 - halfx2)){
            area3 = (long) Math.min(x2 - x1, x4 - x3) * (long)(halfy1 + halfy2 - diffy);
        }else if (diffy <= Math.abs(halfy1 - halfy2)){
            area3 = (long) Math.min(y2 - y1,y4 - y3) * (long)(halfx1 + halfx2 - diffx);
        }else {
            area3 = (long) (halfx1 + halfx2 - diffx) * (long) (halfy1 + halfy2 - diffy);
        }
        long res = area1 + area2 - area3;
        System.out.println(res);
        scan.close();
    }


    //他解：
    //重叠部分存在规律，需要耐心找出
    //注意溢出陷阱, 边长为 10^5 看着没溢出，实际上面积可能为 10^10 溢出了，所以采用long
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int x1 = scanner.nextInt(), y1 = scanner.nextInt();
            int x2 = scanner.nextInt(), y2 = scanner.nextInt();
            int x3 = scanner.nextInt(), y3 = scanner.nextInt();
            int x4 = scanner.nextInt(), y4 = scanner.nextInt();
            // 计算面积并且减去重叠部分的面积
            long area = (long)(x2 - x1) * (y2 - y1) + (long)(x4 - x3) * (y4 - y3);
            int overlapWidth = Math.max(0, Math.min(x2, x4) - Math.max(x1, x3)); // 重叠部分宽度
            int overlapHeight = Math.max(0, Math.min(y2, y4) - Math.max(y1, y3)); // 重叠部分高度
            if (overlapWidth > 0 && overlapHeight > 0) { // 存在重叠部分
                area -= (long)overlapWidth * overlapHeight;
            }
            System.out.println(area);
        }
    }
}
